<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <%
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>会员信息</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <!--bootstrap.min.css-->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <!--font-awesome.css?v=4.4.0-->
    <link href="https://cdn.staticfile.org/font-awesome/4.4.0/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!--bootstrap.min.css-->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <!--custom.css-->
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/plugins/iCheck/custom.css"/>
	<!--style.css-->
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css"/>
	<style type="text/css">
		border-radius: 0px;
}

.btn-primary {
	border-radius: 0px;
	position: relative;
	margin-right: 20px;
}

.pagination {
	margin-right: 10px;
	float: right;
	margin-top: -50px;
}

#jihuo {
	border-radius: 4px;
	}
	</style>
</head>
<body>
<div class="col-md-12">
<div class="panel panel-success" style="margin-top: 20px;">
				 <div class="panel-heading">
				    <h3 class="panel-title">会员列表</h3>
				  </div>
				  <form action="<%=basePath%>User_tableServlet/selectAllInfoAndSearch" method="post">
				  <div class="panel-body">
				  <button class="btn btn-primary pull-right" style="border-radius: 0px;">搜索</button>
				  <div class="pull-right search"><input  style="height: 34px;" name="user_id" value ="${parameter.user_id}"type="text" placeholder="请输入会员编号"></div>
				  </div>
				   	 <table class="table table-bordered table-hover">
				   	 	<tr>
				   	 		<th>会员编号</th>
				   	 		<th>会员姓名</th>
				   	 		<th>邮箱</th>
				   	 		<th>余额</th>
				   	 		<th>是否激活</th>
				   	 		<th>充值</th>
				   	 	</tr>
				   	 	<c:forEach items="${selectInfoAndSearch}" var="member">
           				 <tr id="${member.user_id}">
             				<td>${member.user_id}</td>
              				<td>${member.user_name}</td>
              				<td>${member.user_email}</td>
             				<td>${member.user_money}</td>
             				<td align="center" style="width: 100px;margin: auto;">
				   	 			<input type="button" jihuo="jihuo" onclick="transitionState(this)" user_id="${member.user_id}" acti_id="${member.acti_id}" value="${member.acti_name}"  style="width:48px" class="btn btn-info btn-xs jihuo">
				   	 		</td>
				   	 		<td align="center" style="width: 100px;margin: auto;">
				   	 			<a class="chongzhi" user_id="${member.user_id}"><span class="glyphicon glyphicon-jpy" style="color: yellow;cursor: pointer;"></span></a>
				   	 		</td>
            			</tr>
          				</c:forEach>
				   	 </table>
				   	 </form>
				</div>
			<br />
			<br />
			<br />
			<input type="hidden" name="" id="panduan" value="10"/>
			<input type="hidden" name="" id="huiyuan" value="0" />
					  <div class="pag"></div>
		</div>
	<!--jquery.min.js-->
<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
<!--bootstrap.min.js-->
<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!--jquery.peity.min.js-->
<script src="<%=basePath%>js/plugins/peity/jquery.peity.min.js" type="text/javascript" charset="utf-8"></script>
<!--content.js-->
<script src="<%=basePath%>js/content.js" type="text/javascript" charset="utf-8"></script>
<!--icheck.min.js-->
<script src="<%=basePath%>js/plugins/iCheck/icheck.min.js" type="text/javascript" charset="utf-8"></script>
<!--peity-demo.js-->
<script src="<%=basePath%>js/demo/peity-demo.js" type="text/javascript" charset="utf-8"></script>
<!--layer.min.js-->
<script src="<%=basePath%>js/plugins/layer/layer.min.js" type="text/javascript" charset="utf-8"></script>
<!--pagination.min.js-->
<script src="<%=basePath%>js/jquery-bootstrap-pagination .js" type="text/javascript"></script>
</body>
<script type="text/javascript">

/**
 * 激活
 */
function transitionState(obj){
	if($(obj).val()=='激活'){
		layer.msg('会员已激活',{
			time:1000,
			icon:5
		});
	}else{
		layer.confirm('是否激活', {
			btn: ['是', '否'], //按钮
			yes:function(){
				$.get('${pageContext.request.contextPath}/User_tableServlet/jihuo',{"acti_id":$(obj).attr('acti_id'),"user_id":$(obj).attr('user_id') },function(s){
					if(s==1){
						layer.msg('会员激活', {
							time: 1000, //1s后自动关闭	
							icon: 1
							});
						$(obj).val('激活');
						}
					
				})
			},
			btn2:function(){
				layer.msg('会员未激活', {
					time: 1000, //1s后自动关闭	
					icon: 2
					});
			}
			
			})
	}
		
}

/**
 * 充值
 */


$('.chongzhi').each(function () {
	$(this).click(function(){
		layer.open({
		    area: ['300px', '260px'],
		    title:false,
		    type: 2,
		    closeBtn:0,	            
		    shade: [0.8, '#393D49'],
		    shadeClose:true,
		    anim:3,
		    content: ['${pageContext.request.contextPath}/pages/member/recharge.jsp?user_id='+$(this).attr('user_id'),'no' ],
		    end:function(){
		    	console.log($('#panduan').val());
		    	if($('#panduan').val()==1){
		    		layer.msg('充值成功',{
		    			time:1000
		    		});
		    		$.get('${pageContext.request.contextPath}/User_tableServlet/preChongZhi',{"user_id":$('#huiyuan').val()},function(data){
		    			var mb = JSON.parse(data);
		    			console.log(data);
		    			$('#'+$('#huiyuan').val()+'').find('td:eq(3)').text(mb.user_money);
		    		});
		    		$('#panduan').val(10);
		    	}else if($('#panduan').val()==0){
		    		layer.msg('充值失败',{
		    			time:1000
		    		});
		    		$('#panduan').val(10);
		    	}
		    }
		});
	});
    
});

/**
 * 分页
 */
	$(".pag").pagination({
		total_pages:"${pageCount}",
		current_page:"${pageNum}",
		prev: "上一页",
		next: "下一页",
		display_max: 6,
		callback: function(event, page) {
		$('form').append("<input type='hidden' name='pageNum' value='"+page+"'>");
		$('form').submit();
	}
});
	
</script>
</html>